function multiBonds(main, bonds,k,j)
% This function calculates the new positions for the bonds, and draws them
% on the screen. As this is a seperate function, the original main file
% won't be altered. main holds all needed data, bonds specifies the amount
% of bonds left, and k and j specify which atoms the bonds shall be drawn
% between.
%%
hold on
while bonds > 0
    %% Orthonormalising
    ortho = [cosd(90) -sind(90); sind(90) cosd(90)];
    V = ([(main(main(k).bonds(j)).x - main(k).x) ...
        (main(main(k).bonds(j)).y - main(k).y)])*ortho;
    
    d = 0.05; %width between bondlines.
    %% storing new positions
    V = V/norm(V)*d;
    main(k).x = main(k).x +V(1); 
    main(k).y = main(k).y +V(2);
    main(main(k).bonds(j)).x = main(main(k).bonds(j)).x +V(1); 
    main(main(k).bonds(j)).y = main(main(k).bonds(j)).y +V(2);
            
    %% bond drawing
    if bonds >= 1.0 %as bonds is not allowed to become negative
        line([main(k).x main(main(k).bonds(j)).x], ...
            [main(k).y main(main(k).bonds(j)).y],...
            'LineStyle','-','Color','w') %draws a line
        bonds = bonds - 1; %one line is equil to one bond, and as such 
        %remaining bonds decrease by one
    elseif bonds == 0.5 %if there remains 'half' a bond....
        line([main(k).x main(main(k).bonds(j)).x], ...
            [main(k).y main(main(k).bonds(j)).y],...
            'LineStyle',':','Color','w') %different marker
        bonds = bonds - 0.5; 
    end
end
end